package models

import (
	_ "github.com/jinzhu/gorm/dialects/mysql"
	"github.com/go-xorm/xorm"
)

var engine *xorm.Engine

func Open() *xorm.Engine {
	if engine == nil {
		Db, err := xorm.NewEngine("mysql", "root:root@/titarzhe_blog?charset=utf8&parseTime=true&loc=Asia%2FShanghai")
		if err != nil {
			panic(err)
		}
		engine = Db
	}
	return engine
}

func GetEngine() *xorm.Engine {
	return engine
}
